<!--继承 home.html-->
{% extends 'home.html' %}

<!--设置页面标题-->
{% block title %}CPGC智能助理——工作台{% endblock %}

<!-- 增加自己的css样式 -->
{% block extra_css %}
    <link rel="stylesheet" href="{% static 'css/file/knowbase_list.css' %}">
{% endblock %}

<!--替换主内容区-->
{% block content %}
    <div class="header-bar">
        <h2>文件分割列表</h2>
{#        <button class="btn-create" onclick="toggleFolderForm()" style="margin: 20px 0; height: 40px">#}
{#            新建知识库#}
{#        </button>#}
{##}
{#        <!-- 隐藏的表单，默认不显示  独立出来，进行绝对定位 -->#}
{#        <div id="folder-form" class="folder-form-dropdown" style="display: none; ">#}
{#            <input type="text" id="new-folder-name" placeholder="请输入知识库名称">#}
{#            <button onclick="createFolder()">确认创建</button>#}
{#            <button onclick="toggleFolderForm(false)">取消</button>#}
{#        </div>#}
    </div>

    <!--知识库列表-->
    {% if vectors %}
        <div class="vector-container">
            {% for vc in vectors %}
                <div class="vector-card">
                    <p>分割内容 {{ vc.embedding_content}}</p>
                    <!-- <p><strong>ID:</strong> {{ kb.know_base_id|slice:":8" }}...</p> -->
                    <div class="card-actions">
                        <!-- 详情按钮：跳转或请求详情 -->
                        <a href="{% url 'file-list_html'%}?knowbase_id={{kb.know_base_id}}" class="btn-detail">详情</a>
                        <!-- 删除按钮 -->
                        <button class="btn-delete"
                                onclick="deleteKnowledgeBase('{{ kb.know_base_id }}', '{{ kb.know_base_name }}')">
                            删除
                        </button>
                    </div>
                </div>
            {% endfor %}
        </div>

        <!-- 分页控件 -->
    <div class="pagination">
        {% if page_obj.has_previous %}
            <a href="?file_id={{ file_id }}&page={{ page_obj.previous_page_number }}"
               class="btn-page">上一页</a>
        {% else %}
            <span class="btn-page disabled">上一页</span>
        {% endif %}

        <span class="page-info">
            第 {{ page_obj.number }} 页，共 {{ page_obj.num_pages }} 页
        </span>

        {% if page_obj.has_next %}
            <a href="?file_id={{ file_id }}&page={{ page_obj.next_page_number }}"
               class="btn-page">下一页</a>
        {% else %}
            <span class="btn-page disabled">下一页</span>
        {% endif %}
    </div>
    {% else %}
        <p class="no-data">暂无知识库数据。</p>
    {% endif %}

{% endblock %}

{% block extra_js %}
{#    <script> const KNOWBASE_CREATE_URI = "{% url 'knowbase-create' %}";</script>#}
{#    <script> const KNOWBASE_DELETE_URI = "{% url 'knowbase-delete' %}";</script>#}
{#    <script src="{% static 'js/file/knowbase_create.js' %}"></script>#}
{#    <script src="{% static 'js/file/knowbase_delete.js' %}"></script>#}
{% endblock %}